package toOffer;

/**
 * <h3>toOffer</h3>
 *
 * @author YuanAo
 * @date 2024/6/5 20:27
 * @description <p>leetcode171 简单题</p>
 */
public class No171 {
    public static void main(String[] args) {
        String columnTitle = "ZY";
        System.out.println(titleToNumber(columnTitle));
    }

    public static int titleToNumber(String columnTitle) {
        int result = 0;
        char[] chars = columnTitle.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            result += (chars[i] - 'A' + 1) * Math.pow(26, chars.length - i - 1);
        }
        return result;
    }
}
